import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import Cookies from 'js-cookie'
import config from './assets/js/config.js'
import config1 from './assets/js/config1.js'
Vue.use(ElementUI)
Vue.config.productionTip = false
Vue.prototype.$Cookie = Cookies
Vue.prototype.$config1 = config1
Vue.prototype.$config = config

router.beforeEach((to,from,next)=>{
//	console.log(3333333)
	console.log(store.state.token);
	if(!store.state.token&&to.name!="login"){
		next('/login');
	}else{
			next();
	}
})
var instance = axios.create({
	timeout:10000,
	headers:{'Authorization':"Bearer "+store.state.token}
})

Vue.prototype.$require=instance

let app =new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')





//router.beforeEach((to,from,next)=>{
//	if(to.name=="404"){
//		next({name:"404"})
//	}else{
//		console.log(app.$store.state.token)
//		if(app.$store.state.token){
//			next({path:"/"})
//		}else{
//			 next({path:"/login"})
//		}
//	}
//})
